$(document).ready(function() {
		//
		// POPUP LOGIC
		//--------------------------\
		// v0.1
		//
		//
		popUpOpen = false;
		//
		openPopup = function(name, callback, closecallback){
			//
			popUpOpen = true;
			//
			if(name != undefined){
				$('#popups').data('currentPopup', name);
				$('#popups').data('currentClosecallback', closecallback);
			}
			centerPopup();
			//$('#popups .popup.'+name).fadeIn(500);
			//$('#popups').fadeIn(500);
			$('#popups .popup.'+name).show();
			$('#popups').show();
			//$('#screenfloat').fadeIn(500);
			$('#screenfloat').show();
			//$('#screenfloat').show();
			//$('#screenfloat').animate({'opacity' : 0.5}, 500);
			if(typeof callback == 'function'){
				callback();
			}
			//
		}
		//
		closePopup = function(name){
			//
			popUpOpen = false;
			//
			if(name == undefined){
				name = $('#popups').data('currentPopup');
				callback = $('#popups').data('currentClosecallback');
			}
			//$('#popups .popup.'+name).fadeOut(500);
			//$('#popups').fadeOut(500);
			$('#popups .popup.'+name).hide();
			$('#popups').hide();
			//$('#screenfloat').fadeOut(500);
			$('#screenfloat').hide();
			//$('#screenfloat').animate({'opacity' : 0}, 500, function(){$(this.hide())});
			//
			//articleOpen = false;
			//videoOpen = false;
			//
			if(typeof callback == 'function'){
				callback();
			}
		};
		//
		centerPopup = function(){
			//
			var name = $('#popups').data('currentPopup');
			//
			if(name != undefined){
				//
				//var popupWidth = $('#popups .popup.'+name).width();
				var popupHeight = $('#popups .popup.'+name).height();
				//var windowWidth = $(window).width();
				var windowHeight = $(window).height();
				//var xPos = (windowWidth/2)-(popupWidth/2);
				var yPos = (windowHeight/2)-(popupHeight/2);
				//
				//$('.popup.'+name).css('left', xPos+'px');
				$('.popup.'+name).css('top', yPos+'px');
				//
			}
			//
			if(popUpOpen){
				if($('#popups #at20mc').length < 1){
					var shareBox = $('#at20mc');
					$('#popups').append(shareBox);
				}
			}else{
				if($('body #at20mc').length < 1){
					var shareBox = $('#at20mc');
					$('body').append(shareBox);
				}
			}
			//
		}
		//
		$('#popups .bgClose').click(function(){
			//
			closePopup();
			//
		});
		$('#popups .closeBtn').click(function(){
			//
			closePopup();
			//
		});
		window.setInterval(function(){centerPopup();}, 100);
		//
		
		//
});